using MediatR;
using Microsoft.AspNetCore.Mvc;
using Notification.API.Application.Controller.Notification;
using Notification.API.DTOs.Notifications;
using Notification.API.Utils;
using Notification.Errorcode;
using System.Threading.Tasks;

namespace Notification.API.Commands.Notifications
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class NotificationController : ControllerBase
    {
        private readonly IMediator _mediator;

        public NotificationController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 显示到货检验
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> GetNotification([FromQuery] GetIdNotificationCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 新增到货检验
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> AddProductDetils(AddNotificationCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 删除到货检验
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult> DeleteNotification(DelNotificationCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 查询到货检验列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> SelectNotificationList([FromQuery]SelectNotificationCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 更新到货检验
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult> UpdateNotification(UpdNotificationCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
